{% extends "master.html" %}
{% block subtitle %} - 基础信息 - 商品管理 - 批量修改{% endblock %}

{% block extJS %}
<script language="JavaScript" type="text/javascript">
//<![CDATA[
    function toSbumit(){
        $(".err").removeClass('err');
        var flag = true;
        $(".num").not('[disabled]').each(function(){
            var t = $(this)
            if(t.val() != '' &&  !check_number(t.val())){
                flag = false;
                t.addClass("err")
            }
        });
        
        if(!flag){
            alert('{{MSG_NOT_ALL_PARAMS_OK}}');
            return false;
        }else{
            $("form").submit();
        }
        
    }
    
    function toCancel(){
        return redirect_alert('{{MSG_LEAVE_WITHOUT_SAVING}}',"{{url_for('bpPdt.view')}}");
    }
//]]>
</script>
{% endblock %}




{% block main %}
<div class="container">
    <div class="row">
        <ol class="breadcrumb">
          <li><a href="{{url_for('bpMas.view')}}">基础信息</a></li>
          <li><a href="{{url_for('bpPdt.view')}}">商品管理</a></li>
          <li class="active">批量修改</li>
        </ol>
    </div>
    
    <div class="row">    
        <div class="btn-toolbar pull-right">
            {% if getAllPermission(['PRODUCT_EDIT',])%}
                <div class="btn-group"><button type="button" class="btn btn-default" onclick="return toSbumit()">提交</button></div>
            {% endif %}
            <div class="btn-group"><button type="button" class="btn btn-default" onclick="return toCancel()">取消</button></div>
        </div>
    </div>
    
    <div class="row">
        <form method='post' action="{{url_for('.view',action='saveBatch')}}" enctype="multipart/form-data">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <td>商品编号</td>
                    <td>条码</td>
                    <td>商品名称</td>
                    <td>款号</td>
                    <td>建议采购价格</td>
                    <td>建议销售价格</td>
                </tr>
            </thead>
            <tbody>
                {% for r in result %}
                    {% if r.editable() %}
                    <tr>
                        <td>{{r.no}}<input type="hidden" name="pdt_{{r.id}}" value="{{r.id}}"/></td>
                        <td><input type="text" name="barcode_{{r.id}}" value="{{r.barcode|f}}" class="col-md-2"/></td>
                        <td><input type="text" name="name_{{r.id}}" value="{{r.name}}" class="col-md-2"/></td>
                        <td><input type="text" name="styleNo_{{r.id}}" value="{{r.styleNo|f}}" class="col-md-2"/></td>
                        <td><input type="text" name="pPrice_{{r.id}}" value="{{r.pPrice|f}}" class="num col-md-2"/></td>
                        <td><input type="text" name="sPrice_{{r.id}}" value="{{r.sPrice|f}}" class="num col-md-2"/></td>
                    </tr>
                    {% else %}
                    <tr>
                        <td>{{r.no}}</td>
                        <td><input type="text" name="barcode_{{r.id}}" value="{{r.barcode|f}}" class="col-md-2" disabled="true"/></td>
                        <td><input type="text" name="name_{{r.id}}" value="{{r.name}}" class="col-md-2" disabled="true"/></td>
                        <td><input type="text" name="styleNo_{{r.id}}" value="{{r.styleNo|f}}" class="col-md-2" disabled="true"/></td>
                        <td><input type="text" name="pPrice_{{r.id}}" value="{{r.pPrice|f}}" class="num col-md-2" disabled="true"/></td>
                        <td><input type="text" name="pPrice_{{r.id}}" value="{{r.sPrice|f}}" class="num col-md-2" disabled="true"/></td>
                    </tr>
                    {% endif %}
                {% endfor %}
            <tbody>
        </table>
        </form>
    </div>
</div>
{% endblock %}



{% macro mselect(name,dbobj,value) -%}
    <select name="name" class="col-md-2">
          <option value=""></option>
          {% for o in getMaster(dbobj)%}
              {% if o.id == value%}
                  <option value="{{o.id}}" selected="selected">{{o}}</option>
              {% else %}
                  <option value="{{o.id}}">{{o}}</option>
              {% endif %}
          {% endfor %}
      </select>
{%- endmacro %}